﻿using MediatR;
using Traceability.Commont.Domains.AnimalsDomainFiles;
using Traceability.Commont.DTOs;
using Traceability.Commont.DTOs.CommontFiles;
using Traceability.Commont.Infrastructures.Interfaces;

namespace U.Enterprise.Api.Applications.AdmissionRegistrationFile
{
    public class DeductionDTOListHanser : IRequestHandler<DeductionDTOListCommand, Resqults<DeductionDTO>>
    {
        private readonly IBateRepository<Deductions> dedu;

        public DeductionDTOListHanser(IBateRepository<Deductions> dedu)
        {
            this.dedu = dedu;
        }

        public async Task<Resqults<DeductionDTO>> Handle(DeductionDTOListCommand request, CancellationToken cancellationToken)
        {
            try
            {
                Resqults<DeductionDTO> res = new Resqults<DeductionDTO>();
                var list = from a in dedu.GetAll()
                           select new DeductionDTO
                           {
                               DuctionName = a.DuctionName,
                               Price = a.Price,
                           };
                res.Date = list.ToList();
                return res;
            }
            catch (Exception)
            {

                throw;
            }
        }
    }
}
